package cn.edu.lingnan.dao;

import cn.edu.lingnan.util.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class IAdminDao implements AdminDao{
    //管理员登录
    @Override
    public boolean adminLogin(String username, String password){
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;

        try {
            conn = DBUtil.getInstance().getConnection();
            String sql = "SELECT * FROM administrators WHERE username = ? AND password = ?";
            ps = conn.prepareStatement(sql);
            ps.setString(1, username);
            ps.setString(2, password);
            rs = ps.executeQuery();

            if (rs.next()) {
                return true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.getInstance().close(rs,ps,conn);
        }
        return false;
    }

    public boolean login(){
        return false;
    }
    public boolean query(){
        return false;
    }
}
